package com.example.sprintboot.service;

import com.example.sprintboot.entity.User;
import com.example.sprintboot.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Resource
    private UserMapper userMapper;
    //根据用户名查询
    public User findByUserName(String username) {
       User user = userMapper.findByUserName(username);
        return user;
    }
    //注册
    public void register(String username, String password) {
        userMapper.add(username,password);
    }
    //更新头像
    public void updateAvatar(Integer id, String avatar) {
        userMapper.updateAvatar(id, avatar);
    }
    //根据id查询
    public User findById(Integer id) {
        return userMapper.findById(id);
    }
}
